package cn.s1995.sloth.bizs.entity;

import cn.s1995.sloth.bizs.entity.base.BaseEntity;
import cn.s1995.sloth.common.core.convert.JoinUrlPrefixConvert;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 订单
 *
 * @author sloth
 * @date 2023-12-15 15:26:19
 */
@Data
@Accessors(chain = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Schema(description = "订单")
@TableName("biz_order")
public class Order extends BaseEntity {


	/**
	* ID
	*/
    @TableId(type = IdType.ASSIGN_ID)
    @Schema(description = "ID")
    private Long id;

	/**
	* 订单类型：0-测试单 1-现货单 2-定制单
	*/
    @Schema(description = "订单类型：0-测试单 1-现货单 2-定制单")
    private Integer type;

	/**
	* 状态：1.待付款 2.待发货 3.待收货 4.待评价 5.已完成 6.已取消
	*/
    @Schema(description = "状态：1.待付款 2.待发货 3.待收货 4.待评价 5.已完成 6.已取消")
	@ExcelProperty()
    private Integer state;

	/**
	* 用户id
	*/
    @Schema(description = "用户id")
    private Long uid;

	/**
	* 用户昵称
	*/
    @Schema(description = "用户昵称")
    private String userNickname;

	/**
	* 用户头像
	*/
    @Schema(description = "用户头像")
    private String userAvatar;

	/**
	* 店铺id
	*/
    @Schema(description = "店铺id")
    private Long shopId;

	/**
	* 店铺名称
	*/
    @Schema(description = "店铺名称")
    private String shopName;

	/**
	* 店铺头像
	*/
    @Schema(description = "店铺头像")
	@JsonSerialize(using = JoinUrlPrefixConvert.class)
    private String shopAvatar;

	/**
	* 订单金额
	*/
    @Schema(description = "订单金额")
    private BigDecimal orderAmount;

	/**
	* 实付金额
	*/
    @Schema(description = "实付金额")
    private BigDecimal actualAmount;

	/**
	* 税金额
	*/
    @Schema(description = "税金额")
    private BigDecimal taxAmount;

	/**
	* 运费金额
	*/
    @Schema(description = "运费金额")
    private BigDecimal freightAmount;

	/**
	* 优惠总额
	*/
    @Schema(description = "优惠总额")
    private BigDecimal reduceAmount;

	/**
	* 产品名称
	*/
    @Schema(description = "产品名称")
    private String prodName;

	/**
	* 产品总数
	*/
    @Schema(description = "产品总数")
    private Integer num;

	/**
	* 是否支付
	*/
    @Schema(description = "是否支付")
    private Boolean isPayed;

	/**
	* 支付方式：1.微信支付 2.支付宝 3.手动代付 4.paypal 5.google 6.apple 7.stripe
	*/
    @Schema(description = "支付方式：1.微信支付 2.支付宝 3.手动代付 4.paypal 5.google 6.apple 7.stripe")
    private Integer payMethod;

	/**
	 * 支付流水id
	 */
	@Schema(description = "支付流水id")
	private Long payFlowId;

	/**
	* 第三方交易id
	*/
    @Schema(description = "第三方交易id")
    private String transactionId;

	/**
	 * 捕获id(捕获支付的paypal生成的ID)
	 */
	@Schema(description = "捕获id(捕获支付的paypal生成的ID)")
	private String captureId;

	/**
	* 配送类型：1.物流
	*/
    @Schema(description = "配送类型：1.物流")
    private Integer deliveryType;

	/**
	* 物流单号
	*/
    @Schema(description = "物流单号")
    private String logisticsNo;

	/**
	* 订单地址id
	*/
    @Schema(description = "订单地址id")
    private Long orderAddressId;

	/**
	* 是否已收货
	*/
    @Schema(description = "是否已收货")
    private Boolean isReceiving;

	/**
	* 是否自动收货
	*/
    @Schema(description = "是否自动收货")
    private Boolean isAutoReceiving;

	/**
	* 是否自动取消订单
	*/
    @Schema(description = "是否自动取消订单")
    private Boolean isAutoCancel;

	/**
	* 付款时间
	*/
    @Schema(description = "付款时间")
    private LocalDateTime payTime;

	/**
	* 发货时间
	*/
    @Schema(description = "发货时间")
    private LocalDateTime deliveryTime;

	/**
	* 收货时间
	*/
    @Schema(description = "收货时间")
    private LocalDateTime receivingTime;

	/**
	* 完成时间
	*/
    @Schema(description = "完成时间")
    private LocalDateTime completeTime;

	/**
	* 取消时间
	*/
    @Schema(description = "取消时间")
    private LocalDateTime cancelTime;

	/**
	* 用户优惠券id
	*/
    @Schema(description = "用户优惠券id")
    private Long userCouponId;

	/**
	* 用户优惠码id
	*/
    @Schema(description = "用户优惠码id")
    private Long userPromoCodeId;

	/**
	* 优惠券金额
	*/
    @Schema(description = "优惠券金额")
    private BigDecimal couponAmount;

	/**
	* 优惠码金额
	*/
    @Schema(description = "优惠码金额")
    private BigDecimal promoCodeAmount;

	/**
	* 来源：1.APP 2.H5 3.小程序
	*/
    @Schema(description = "来源：1.APP 2.H5 3.小程序")
    private Integer source;

	/**
	* 订单关闭原因：1.超时未支付 2.退款关闭 3.买家取消 15.已通过货到付款交易
	*/
    @Schema(description = "订单关闭原因：1.超时未支付 2.退款关闭 3.买家取消 15.已通过货到付款交易")
    private Integer closeType;

	/**
	* 订单备注
	*/
    @Schema(description = "订单备注")
    private String remark;

	/**
	* 删除标识
	*/
	@TableLogic
	@TableField
    @Schema(description = "删除标识", hidden = true)
    private Boolean delFlag;




	/**
	 * 订单项
	 */
	@Schema(description = "订单项")
	@TableField(exist = false)
	private List<OrderItem> orderItems;

	/**
	 * 订单地址
	 */
	@Schema(description = "订单地址")
	@TableField(exist = false)
	private OrderAddress orderAddress;
}
